import request from '@/utils/request'

// 品牌属性的接口
/* 
三级联动接口地址
/admin/product/getCategory1 一级接口不需要传参数
/admin/product/getCategory2/{category1Id} 二级接口需要传一级的id
/admin/product/getCategory3/{category2Id} 三级需要传二级的id
*/

export const getCategory1 = () => {
    return request({
        url: '/admin/product/getCategory1',
        method: 'get'
    })
}
// 二级
export const getCategory2 = (category1Id) => {
    return request({
        url: `/admin/product/getCategory2/${category1Id}`,
        method: 'get'
    })
}
// 三级
export const getCategory3 = (category2Id) => {
    return request({
        url: `/admin/product/getCategory3/${category2Id}`,
        method: 'get'
    })
}

// 获取商品的属性
export const getattrInfoList = (options) => {
    return request({
        url: `/admin/product/attrInfoList/${options.item1Id}/${options.item2Id}/${options.item3Id}
        `,
        method: 'get'
    })
}

// 保存属性值 /admin/product/saveAttrInfo post
/* 
{
  "attrName": "string",
  "attrValueList": [
    {
      "attrId": 0,
      "id": 0,
      "valueName": "string"
    }
  ],
  "categoryId": 0,
  "categoryLevel": 0,
  "id": 0
}
*/

export const saveAttrInfo = function (data) {
    return request({
        url: '/admin/product/saveAttrInfo',
        method: 'post',
        data
    })
}